<template>
  <a-card>
    <div style="margin: auto; width: 100%; height: 80vh">
      <FlowDesignTCD
        v-model:edgeModel="edgeModel"
        v-model:nodeModel="nodeModel"
        :flowData="g6data"
        @save="save"
      ></FlowDesignTCD>
    </div>
  </a-card>
</template>
<script>
  // import { Add, Get, Update } from '@/api/flow/api'

  export default {
    data() {
      return {
        nodeModel: {
          label: '',
          forms: '',
          handleNode: '',
          strategy: {
            processorType: '1', // 策略处理人
            defaultHandlerName: '', // 默认处理人姓名
            defaultHandlerIds: '', // 默认处理人ids
          },
          targetKeys: [], // 按钮穿梭框数据
        },
        edgeModel: {
          label: '',
          sql: '',
          organizeData: [
            {
              left: '',
              fieldType: '',
              equal: '0',
              value: '0',
              right: '',
              andor: '',
              organizeName: '',
            },
          ],
        },
        g6data: {
          flowInfo: {},
          g6data: {
            database: [],
          },
        }, // 保存的json数据包
      }
    },
    created() {
      // var that = this
      // if (that.$route.query.id != undefined) {
      //   Get({ id: that.$route.query.id }).then((res) => {
      //     this.g6data = JSON.parse(res.content.designerJSON)
      //     // console.log(this.g6data)
      //     this.isshow = true
      //   })
      // } else {
      //   this.isshow = true
      //   this.g6data = {
      //     flowInfo: {},
      //     g6data: {
      //       database: [],
      //     },
      //   }
      // }
    },
    methods: {
      save(data, info) {
        console.log('save', data, info)
        var jsonData = {
          DictId: info.dictId,
          Title: info.name,
          DesignerJSON: JSON.stringify({
            g6data: data,
            flowInfo: info,
          }),
          Note: info.note,
        }
        console.log('jsonData', jsonData)
      },
    },
  }
</script>
